/***************************************************************
 *
 * (c) 2008 Markus Dittrich 
 *
 * This program is free software; you can redistribute it 
 * and/or modify it under the terms of the GNU General Public 
 * License Version 3 as published by the Free Software Foundation. 
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License Version 3 for more details.
 *
 * You should have received a copy of the GNU General Public 
 * License along with this program; if not, write to the Free 
 * Software Foundation, Inc., 59 Temple Place - Suite 330, 
 * Boston, MA 02111-1307, USA.
 *
 ****************************************************************/

#ifndef TICKLABELMANAGER_H
#define TICKLABELMANAGER_H


/** STL includes */
#include <vector>
#include <string>

/* Qt includes */
#include <QString>

/** boost includes */
#include <boost/array.hpp>
#include <boost/utility.hpp>


/*****************************************************************
 *
 * TickLabelManager computes and provides the tick locations
 * for a particular axes based on the global min and max 
 * values displayed
 *
 *****************************************************************/
class TickLabelManager : public boost::noncopyable
{

public:

  explicit TickLabelManager();

  void initialize(double minData, double maxData);
  const std::vector<double>& get_tick_values() const;
  const std::vector<QString>& get_label_values() const;


private:

  /** member functions */
  void compute_tick_values_();
  void check_interval_boundaries_for_ticks_();
  double compute_start_tick_position_();
  void generate_tick_labels_();
  int compute_divisor_(double interval);
  double compute_diff_magnitude_();
  double compute_diff_exponent_();

  /** data members */
  double Min_;
  double Max_;
  double Diff_;
  double Interval_;
  int Divisor_;

  /* main storage arrays */
  std::vector<QString> Labels_;
  std::vector<double> TickLocations_;

  /* epsilon used to test if a potential tick mark location 
   * matches MIN_ or MAX_ */
  const double Epsilon_;

  /* array containing the intervals used for dividing the axis  */
  boost::array<double,7> Intervals_;
};

#endif
